<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title><if condition="$type eq 1">在岗<else/>出差</if>-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<link rel="stylesheet" href="__PUBLIC__/mobile/css/mobiscroll.min.css">
</head>
<body>
<div class="schedule_add">
	<div class="header">
		<a class="back_btn" href="javascript:history.back(-1);"></a>
		<if condition="$data eq NULL">添加<else/>编辑</if>日程
	</div>
	<include file="Include:commu_menu" />
	<div class="schedule_add_title">
		<if condition="$type eq 1">
			<img class="det_bg" src="__PUBLIC__/mobile/images/index/zg_bg.jpg">
		<else/>
			<img class="det_bg" src="__PUBLIC__/mobile/images/index/cc_bg.jpg">
		</if>
		<div class="txt">
			<if condition="$type eq 1">
				<img src="__PUBLIC__/mobile/images/index/tit_icon1.png">
			<else/>
				<img src="__PUBLIC__/mobile/images/index/tit_icon2.png">
			</if>
			<span>
				<if condition="$type eq 1">
					在 岗
				<else/>
					出 差
				</if>
			</span>
			<p><if condition="$end eq NULL">{$start}<else/>{$start} 至 {$end}</if></p>
		</div>
	</div>
	<div class="btn_box <if condition="$type eq 1">zg<else/>cc</if> text_c">
	<foreach name="fill_post" item="vo">
		<a href="javascript:void(0)" fill_post="{$vo['name1']}" <if condition="$data['fill_post'] eq $vo['name1']">class="active"</if>>{$vo['name2']}</a>
	</foreach>
	</div>
	<div class="inp_list all">
		<ul>
			<li>
				<if condition="$data neq NULL">
					<if condition="$data['noedit'] neq 1">
						<select name="pid" id="md-country" required data-icon="location">
							<foreach name="plist" item="vo">
								<option value="{$vo['id']}" <if condition="$data['pid'] eq $vo['id']">selected</if>>[{$vo['project_num']}]{$vo['project_name']}</option>
							</foreach>
						</select>
					<else/>
						[{$data['project_num']}]{$data['project_name']}
					</if>
				<else/>
					<select name="pid" id="md-country" required data-icon="location">
						<option value="-10">请选择项目编号</option>
						<foreach name="plist" item="vo">
							<option value="{$vo['id']}">[{$vo['project_num']}]{$vo['project_name']}</option>
						</foreach>
					</select>
				</if>
			</li>
			<li>
				<if condition="$data neq NULL">
					<if condition="$data['noedit'] neq 1">
						<input class="required-text" name="matter_id" type="text" placeholder="请填写任务单号" value="{$data['matter_id']}">
					<else/>
						{$data['matter_id']}
					</if>
				<else/>
					<input class="required-text" name="matter_id" type="text" placeholder="请填写任务单号">
				</if>
				
			</li>
			<li>
				<if condition="$data neq NULL">
					<if condition="$data['noedit'] neq 1">
						<select name="work_type" id="lx-country" required data-icon="location">
							<option value="-10">请选择工作类型</option>
							<foreach name="work_type" item="vo">
								<option value="{$vo['name1']}" <if condition="$data['work_type'] eq $vo['name1']">selected</if>>{$vo['name2']}</option>
							</foreach>
						</select>
					<else/>
						{$data['work_name']}
					</if>
				<else/>
					<select name="work_type" id="lx-country" required data-icon="location">
						<option value="-10">请选择工作类型</option>
						<foreach name="work_type" item="vo">
							<option value="{$vo['name1']}">{$vo['name2']}</option>
						</foreach>
					</select>
				</if>
			</li>
			<li>
				<if condition="$data neq NULL">
					<if condition="$data['noedit'] neq 1">
						<input class="required-text" name="work_content" type="text" placeholder="请填写工作内容" value="{$data['work_content']}">
					<else/>
						{$data['work_content']}
					</if>
				<else/>
					<input class="required-text" name="work_content" type="text" placeholder="请填写工作内容">
				</if>
			</li>
		</ul>
	</div>
	<div class="build_btn paddbox"><div><button type="submit" class="sub_btn disabled <if condition="$type eq 1">zg<else/>cc</if>" disabled>保 存</button></div></div>
	<input class="hide_inp" type="hidden" start="{$start}" end="{$end}" ttype="{$type}">
</div>
<include file="Include:javascript" />
<script src="__PUBLIC__/mobile/js/mobiscroll.min.js"></script>
<script>
    $(function(){
		$('.btn_box a').click(function(){
			$(this).addClass('active').siblings().removeClass('active');
		})
		$('#md-country').mobiscroll().select({
			theme: 'ios',
			display: 'bottom',
			placeholder: 'Country',
			lang: 'zh'
		});
		$('#lx-country').mobiscroll().select({
			theme: 'ios',
			display: 'bottom',
			placeholder: 'Country',
			lang: 'zh'
		});
		submit();
		$('.btn_box a').click(function(){
			submit();
		})
		$('#md-country').change(function(){
			submit();
		})
		$('#lx-country').change(function(){
			submit();
		})
		$('.required-text').blur(function(){
			submit();
		})
		//提交
		function submit(){
            var tag = true;
			
			if($('.btn_box .active').length<1){
				tag = false;
                $('.sub_btn').addClass('disabled').attr('disabled',true);
			}
            if($('#md-country').val()==-10){
                tag = false;
                $('.sub_btn').addClass('disabled').attr('disabled',true);
            }
			if($('#lx-country').val()==-10){
                tag = false;
                $('.sub_btn').addClass('disabled').attr('disabled',true);
            }
			$('.required-text').each(function(){
				if($(this).val()==''){
					tag = false;
					$('.sub_btn').addClass('disabled').attr('disabled',true);
				}
			})
            if(tag){
                $('.sub_btn').removeClass('disabled').attr('disabled',false);
            }
        }
		$('.sub_btn').click(function(){
			var val1 = $("#md-country").val(),
				val2 = $("[name='matter_id']").val(),
				val3 = $("#lx-country").val(),
				val4 = $("[name='work_content']").val(),
				active = $('.btn_box .active').attr('fill_post'),
				start = $('.hide_inp').attr('start'),
				end = $('.hide_inp').attr('end'),
				type = $('.hide_inp').attr('ttype'),
				id = "{$data['id']}";
			if(id){
				$.ajax({
					type:"POST",
					async:false,
					dataType:"json",
					data:{"pid":val1,"matter_id":val2,"work_type":val3,"work_content":val4,"fill_post":active,"id":id},
					url:"__APP__/Mobile/Index/schedule_list_doedit",
					success : function (data) {
						success_pop(data['status'],data['msg'],1,'__APP__/Mobile/Index/schedule_list');
					}
				})
			}else{
				$.ajax({
					type:"POST",
					async:false,
					dataType:"json",
					data:{"pid":val1,"matter_id":val2,"work_type":val3,"work_content":val4,"fill_post":active,"start":start,"end":end,"type":type},
					url:"__APP__/Mobile/Index/schedule_list_doadd",
					success : function (data) {
						success_pop(data['status'],data['msg'],1,'__APP__/Mobile/Index/schedule_list');
					}
				})
			}
		})
    })
</script>
</body>
</html>